package com.wangxinyuchuan.demo.prototype.homework;

/**
 * @author wangxinyuchuan
 * @date 2023/4/14 6:44 PM
 *
 * 方法二：
 * 使用Template Method模式，直接让Product类实现模版方法createClone()
 * MessageBox和UnderlinePen类直接继承此类，只需要实现use方法即可复用代码
 */
public abstract class Product {

    public abstract void use(String s);

    public com.wangxinyuchuan.demo.prototype.Product createClone() {
        com.wangxinyuchuan.demo.prototype.Product product = null;

        try {
            product = (com.wangxinyuchuan.demo.prototype.Product) clone();
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
        return product;
    }
}
